<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
    />
    <meta name="description" content="Draw a box." />
    <meta name="quarkgis-sandcastle-labels" content="Development" />
    <title>QuarkGIS Demo</title>
    <script type="text/javascript" src="../Sandcastle-header.js"></script>
    <script
      type="text/javascript"
      src="../../../Build/QuarkGISUnminified/QuarkGIS.js"
      nomodule
    ></script>
    <script type="module" src="../load-quarkgis-es6.js"></script>
  </head>
  <body
    class="sandcastle-loading"
    data-sandcastle-bucket="bucket-requirejs.html"
  >
    <style>
      @import url(../templates/bucket.css);
    </style>
    <div id="quarkgisContainer" class="fullSize"></div>
    <div id="loadingOverlay"><h1>Loading...</h1></div>
    <div id="toolbar"></div>
    <script id="quarkgis_sandcastle_script">
      function startup(QuarkGIS) {
        "use strict";
        //Sandcastle_Begin
        // Create the viewer.
        var viewer = new QuarkGIS.Viewer("quarkgisContainer");
        var scene = viewer.scene;

        // Draw a red box and position it on the globe surface.

        var dimensions = new QuarkGIS.Cartesian3(400000.0, 300000.0, 500000.0);
        // Box geometries are initially centered on the origin.
        // We can use a model matrix to position the box on the
        // globe surface.
        var positionOnEllipsoid = QuarkGIS.Cartesian3.fromDegrees(-105.0, 45.0);
        var boxModelMatrix = QuarkGIS.Matrix4.multiplyByTranslation(
          QuarkGIS.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
          new QuarkGIS.Cartesian3(0.0, 0.0, dimensions.z * 0.5),
          new QuarkGIS.Matrix4()
        );
        // Create a box geometry.
        var boxGeometry = QuarkGIS.BoxGeometry.fromDimensions({
          vertexFormat: QuarkGIS.PerInstanceColorAppearance.VERTEX_FORMAT,
          dimensions: dimensions,
        });
        // Create a geometry instance using the geometry
        // and model matrix created above.
        var boxGeometryInstance = new QuarkGIS.GeometryInstance({
          geometry: boxGeometry,
          modelMatrix: boxModelMatrix,
          attributes: {
            color: QuarkGIS.ColorGeometryInstanceAttribute.fromColor(
              new QuarkGIS.Color(1.0, 0.0, 0.0, 0.5)
            ),
          },
        });
        // Add the geometry instance to primitives.
        scene.primitives.add(
          new QuarkGIS.Primitive({
            geometryInstances: boxGeometryInstance,
            appearance: new QuarkGIS.PerInstanceColorAppearance({
              closed: true,
            }),
          })
        );
        //Sandcastle_End
        Sandcastle.finishedLoading();
      }
      if (typeof QuarkGIS !== "undefined") {
        window.startupCalled = true;
        startup(QuarkGIS);
      }
    </script>
  </body>
</html>
